<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <ul></ul>

    <script src="/public/axios.min.js"></script>
    <script>
        let button = document.querySelector('button');
        let ul = document.querySelector('ul');

        getData();

        // 轮询：轮流查询，每隔一段时间重新向服务端发送请求
        setInterval(() => {
            getData();
        }, 1000);

        async function getData() {
            ul.innerHTML = '';
            let {data} = await axios({
                url: '/'
            });

            // console.log('data', data);
            data.forEach(d => {
                let li = document.createElement('li');
                li.innerHTML = d.name;
                ul.appendChild(li);
            })
        }
    </script>
</body>
</html>